package com.example.cart.repository;

import static androidx.room.OnConflictStrategy.IGNORE;
import static androidx.room.OnConflictStrategy.REPLACE;

import android.database.Cursor;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.cart.dto.Goods;

import java.util.List;

/**
 * <a href="https://developer.android.com/codelabs/basic-android-kotlin-training-persisting-data-room?hl=zh-cn#5">参考文档</a>
 */
@Dao
public interface GoodsDao {
    @Insert(onConflict = REPLACE)
    void insert(Goods goods);

    @Delete
    void delete(Goods goods);

    @Update
    void update(Goods goods);

    @Query("select * from goods where id = :id")
    Goods queryById(int id);

    @Query("select * from goods limit :offset,:size")
    List<Goods> page(int offset, int size);

    @Query("select * from goods ")
    Cursor all();
}
